/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.groupb.circus.Databases;

import com.groupb.circus.interfaces.DBAction;
import com.groupb.circus.interfaces.DBActionResult;
import com.groupb.circus.interfaces.DBManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xmldb.api.base.ResourceIterator;
import org.xmldb.api.base.ResourceSet;
import org.xmldb.api.base.XMLDBException;
import org.xmldb.api.modules.XMLResource;

/**
 *
 * @author bhavna
 */
public class DAOIm {

    private static DAOIm daoinstance;
    private static final Log LOG = LogFactory.getLog(DAOIm.class);
    List<Images> prueba = new ArrayList();
    DBActionResult dbAr = new DBActionResultIm();
    ResourceSet result = null;

    /**
     * Singleton
     */
    private DAOIm() {
    }

    public static DAOIm getInstance() {
        if (daoinstance == null) {
            daoinstance = new DAOIm();
        }
        return daoinstance;
    }

    /*
     * Helpful method that internally processes the queries
     */
    private List processQuery(String ActionId, String aParameters) throws XMLDBException, InstantiationException, IllegalAccessException {

        
        DBManager gestorDB = DBManagerIm.getInstance();
        DBActionResult resultadoBD = (DBActionResult) gestorDB.execute(new DBActionIm(ActionId, new String[]{aParameters}));
        
 
        return resultadoBD.getResult();
    }
    
    
    
    public List TitleSearchPhoto(String aParameters) throws XMLDBException, InstantiationException, IllegalAccessException{
        
        List res = processQuery("query.titleSearchPhoto", aParameters);
        return res;
    }
    
    public List KeywordSearchPhoto(String aParameters) throws XMLDBException, InstantiationException, IllegalAccessException{
        
        List res = processQuery("query.keywordSearchPhoto", aParameters);
        return res;
    }
    
    public List UserSearchPhoto(String aParameters) throws XMLDBException, InstantiationException, IllegalAccessException{
        
        List res = processQuery("query.authorSearchPhoto", aParameters);
        return res;
    }
    
    public List LocalizationSearchPhoto(String aParameters) throws XMLDBException, InstantiationException, IllegalAccessException{
        
        List res = processQuery("query.localizationSearchPhoto", aParameters);
        return res;
    }
    
     public List TitleNews(String aParameters) throws XMLDBException, InstantiationException, IllegalAccessException{
        
        List res = processQuery("news.wordintitleSearchNew", aParameters);
        return res;
     }
     
     public List ParagraphWord(String aParameters) throws XMLDBException, InstantiationException, IllegalAccessException{
        
        List res = processQuery("news.wordinbodySearchNew", aParameters);
        return res;
     }
    
      public List NewsAuthor(String aParameters) throws XMLDBException, InstantiationException, IllegalAccessException{
        
        List res = processQuery("news.authormews", aParameters);
        return res;
     }
    
    
    
    
    
    
    
    
}
